<template>
  <el-dialog title="查看附件" :visible.sync="OpType.OpenFJ" width="600px" append-to-body>
      <div class="el-dialog-div">
        <el-form ref="form-fj" label-width="80px">
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="附件" prop="displafile_fj">
                <ul>
                  <li v-for="(file, idx) in upload.uploadFiles" :key="idx">
                    <span  @click.stop="doDownloadFile({classid:file.classid, fileid:file.fileid})">
                      <el-link href="#" type="primary">{{ file.name }}</el-link>
                    </span>
                  </li>
                </ul>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelBtn" @click="gbfj"> 关 闭 </el-button>
      </div>
    </el-dialog>
</template>

<script>

import {
  getListData_fj,
  downloadFile,
} from '@/api/syfxxtApi/khfw/FuncTest/api.js'
export default {
  data() {
    return {
      url: '',
      OpType: {
        OpenFJ: false,
      },
      upload: {  //上传配置
        uploadVisible: false, //上传项是否显示，在查看时不显示
        uploadFiles: [], //已上传文件列表
      },
    }
  },
  props: {
    id: {
      type: String,
      default: ""
    },
  },
  mounted() {
  },
  computed: {

  },
  methods: {
    //处理查看附件按钮事件
    doViewFJ(param,elr) {
      this.$getListData_fj(param, elr).then((res) => {
        if (res.success) {
          this.upload.uploadFiles = res.rows;
          this.upload.uploadFiles.forEach(file => {
            file.name = file.filename;
            file.status = 'success';
          });
          if (this.upload.uploadFiles.length > 0) {
            this.OpType.OpenFJ = true;
          } else {
            this.$message.info({ content: '无附件!', placement: 'center' })
          }
        } else {
          this.$message.error({ content: '下载附件失败!', placement: 'center' })
        }
      });
    },
    //处理查看附件按钮关闭事件
    dkfj(rc,url) {
      this.url = url;
      this.doViewFJ(rc,url)
    },
    //处理查看附件按钮关闭事件
    gbfj() {
      this.OpType.OpenFJ = false;
    },
    //处理下载附件按钮事件
    doDownloadFile(param) {
      try {
        return this.$downloadFile(param, this.url);
      } catch (error) {
      }
    },

  }
};
</script>

<style scoped>
.inbo {
  display: inline-block;
}

.pagination-container {
  /* background: #fff; */
  padding: 23px 0 20px;
}

.pagination-container.hidden {
  display: none;
}
</style>